package com.baide.xguangji.swing;

import javax.swing.table.AbstractTableModel;
import java.util.List;
import java.util.Map;

public class TableModel extends AbstractTableModel {

    String[] cName = new String[]{"序号", "运单号", "重量", "商品名称", "申报日期"};
    List<Map<String, Object>> data;

    public TableModel(List<Map<String, Object>> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return data.size();
    }

    @Override
    public int getColumnCount() {
        return cName.length;
    }

    @Override
    public String getColumnName(int column) {
        return cName[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Map<String, Object> map = data.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return rowIndex + 1;
            case 1://运单号
                return "这是运单号";
            case 2:
                return "这是重量";
            case 3:
                return "商品名称";
            case 4:
                return "申报日期";
        }
        return "";
    }
}
